~ chicken-core (chicken-5) /manual/Module (chicken bitwise)


 1[[tags: manual]]
 2[[toc:]]
 3
 4== Module (chicken bitwise)
 5
 6Binary integer operations are provided by the {{(chicken bitwise)}}
 7module.
 8
 9=== Binary integer operations
10
11<procedure>(bitwise-and N1 ...)</procedure>
12<procedure>(bitwise-ior N1 ...)</procedure>
13<procedure>(bitwise-xor N1 ...)</procedure>
14<procedure>(bitwise-not N)</procedure>
15<procedure>(arithmetic-shift N1 N2)</procedure>
16
17Binary integer operations. {{arithmetic-shift}} shifts the argument {{N1}} by
18{{N2}} bits to the left. If {{N2}} is negative, then {{N1}} is shifted to the
19right. These operations only accept exact integers.
20
21==== bit->boolean
22
23<procedure>(bit->boolean N INDEX)</procedure>
24
25Returns {{#t}} if the bit at the position {{INDEX}} in the integer
26{{N}} is set, or {{#f}} otherwise. The rightmost/least-significant bit
27is bit 0.
28
29==== integer-length
30
31<procedure>(integer-length N)</procedure>
32
33Returns the number of bits needed to represent the exact integer N in
342's complement notation.
35
36---
37Previous: [[Module (chicken base)]]
38
39Next: [[Module (chicken blob)]]
Trap